/**
 * 
 */
package memsim;

/**
 *
 * @author Alan
 */
public class Register {

    private int[] registers; //main storage
    int size = 0; // number of registers
    int length = 0;// 32-bit or 64-bit
    final int INTEGER = 0;
    final int FLOAT = 1;
    //more type vars if needed

    boolean general = false; //is it a general purpiose reg or not, may need to make ints if more than 2 purposes
    int regType = -1;
    


   /**
    * The constuctor for a set of registers
    * 
    * @param totalNum   total number of registers that will be contained in the instance
    * @param type       type of data the registers will hold
    * @param bits       the number of bits for the data
    * @param purpose    general purpose or specail purpose
    */
    public Register(int totalNum, int type, int bits, boolean purpose)
    {
        regType = type;
        length = bits;
        general = purpose;
        registers = new int[totalNum];
        size = totalNum;

        for(int i = 0; i < totalNum; i++)
        {
            registers[i] = 0;
        }
    }

    /**
     * put a value into a register
     *
     * @param regNum    number of the register the value will go into
     * @param value     the value being put into the register
     */
    public void setValue(int regNum, int value)
    {
        registers[regNum] = value;
    }

    /**
     * get a value from a register
     *
     * @param regNum    number of the register to be read
     * @return          the value in the register
     */
    public int getValue(int regNum)
    {
        return registers[regNum];
    }

    /**
     * clear out all the registers
     */
    public void clearRegs()
    {
        for(int i = 0; i < registers.length; i++)
        {
            registers[i] = 0;
        }
    }

    /**
     * Method to get a copy of the registers array
     *
     * @return          array containing all the data from the registers
     */
    public int[] getRegData()
    {
        return registers;
    }


}
